package com.gwcm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gwcm.exception.BusinessException;
import com.gwcm.model.dto.orderInfo.OrderInfoQueryRequest;
import com.gwcm.model.dto.orderInfo.PosSaleOrderQueryRequest;
import com.gwcm.model.vo.OrderInfoVo;
import com.gwcm.model.vo.PosSaleOrderVo;
import com.gwcm.service.OrderInfoService;
import com.yhz.commonutil.common.BaseResponse;
import com.yhz.commonutil.common.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.map.MapperConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orderInfo")
@Api(tags = "订单信息接口")
public class OrderInfoController {
    @Autowired
    public OrderInfoService orderInfoService;

//    @ApiOperation("分页查询订单信息接口")
//    @PostMapping("/page")
//    public BaseResponse<IPage<OrderInfoVo>> pageModuleTopic(@RequestBody OrderInfoQueryRequest orderInfoQueryRequest) throws BusinessException {
//        IPage<OrderInfoVo> orderInfoVoIPage = orderInfoService.pageList(orderInfoQueryRequest);
//        return ResultUtils.success(orderInfoVoIPage);
//    }

    @ApiOperation("分页查询收银销售订单接口")
    @PreAuthorize("hasAuthority('order:pos:list')")
    @PostMapping("/page")
    public BaseResponse<IPage<PosSaleOrderVo>> pageModuleTopic(@RequestBody PosSaleOrderQueryRequest posSaleOrderQueryRequest) throws BusinessException {
        IPage<PosSaleOrderVo> posSaleOrderVoIPage = orderInfoService.pageList(posSaleOrderQueryRequest);
        return ResultUtils.success(posSaleOrderVoIPage);
    }
    @ApiOperation("通过saleId获得销售明细")
    @GetMapping("/saleItem")
    public BaseResponse selectSaleItemBySaleId(@RequestParam("saleId") Long saleId){
        return ResultUtils.success(orderInfoService.selectSaleItemBySaleId(saleId));
    }
}
